package com.chinasofti.thread02;

public class Demo01 {
    //TIMED_WAITING
    public static void main(String[] args) throws InterruptedException {
        //定义一个内部线程
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("2.执行thread.start后，线程的状态"+Thread.currentThread().getState());
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("4.执行thread.sleep100后，线程的状态"+Thread.currentThread().getState());
            }
        });
        //获取start 之前的状态
        System.out.println("1.通过new初始化一个线程，但是没有调用start之前，线程的状态"+thread.getState());
        //启动线程
        thread.start();
        //休眠50
        Thread.sleep(50);
        //因为thread1需要休眠100毫秒
        System.out.println("3.执行sleep50，线程状态"+thread.getState());

        //
        Thread.sleep(100);
        System.out.println("5.线程执行完毕，线程状态"+Thread.currentThread().getState() +"\n");
    }
}